package main

import "strconv"

func main() {
	println(reorderedPowerOf2(461))
}

func reorderedPowerOf2(n int) (res bool) {
	lover := [][]string{
		{"1"},
		{"2", "4", "8"},
		{"16", "32", "64"},
		{"128", "256", "512"},
		{"1024", "2048", "4096", "8192"},
		{"16384", "32768", "65536"},
		{"131072", "262144", "524288"},
		{"1048576", "2097152", "4194304", "8388608"},
		{"16777216", "33554432", "67108864"},
		{"134217728", "268435456", "536870912"},
	}
	res = true
	nStr := strconv.Itoa(n)
	n = len(nStr)
	m := make(map[uint8]int)
	if nStr == "1" {
		return
	}

	for i := range nStr {
		m[nStr[i]]++
	}

	for _, str := range lover[n] {
		mTmp := make(map[uint8]int)
		res = true
		for i := range str {
			mTmp[str[i]]++
		}
		for v, k := range m {
			if mTmp[v] != k {
				res = false
				break
			}
		}
		if res {
			return
		}
	}
	return false
}
